﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Reflection;
using System.IO;

namespace FlowBasis.Util
{
    public static class AssemblyHelper
    {
        /// <summary>
        /// Returns local directory for assembly without trailing slash.
        /// </summary>
        /// <param name="assembly"></param>
        /// <returns></returns>
        public static string GetAssemblyDirectory(Assembly assembly)
        {
            if (assembly == null)
                throw new ArgumentNullException("assembly");

            var uri = new UriBuilder(assembly.CodeBase);
            string path = Uri.UnescapeDataString(uri.Path);

            return Path.GetDirectoryName(path);
        }
    }
}
